<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8">
		<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
		<link rel="stylesheet" type="text/css" href="css/years.css"/>
		<title>跨年大礼包</title>
	</head>
	<body>
		<div id="web">
			<div class="years-head">
				<img src="img/years/years_head.jpg"/>
			</div>
			<div class="years_time">
				<div class="times_img">
					<img src="img/years/years_time.png"/>
					<div class="title_size">
						<div class="title_times">
							<div class="times1">
								00
							</div>
							<div class="times1">
								00
							</div>
							<div class="times1">
								00
							</div>
							<div class="times1">
								00
							</div>
						</div>
						<div class="title-data">
							<div class="data1">
								天
							</div>
							<div class="data1">
								时
							</div>
							<div class="data1">
								分
							</div>
							<div class="data1">
								秒
							</div>
						</div>
					</div>
				</div>
			</div>
			<div class="years_bottom">
					<div class="bottom-botton">
						跨年狂欢  惊喜大促
					</div>
			</div>
		</div>
	</body>
	<script type="text/javascript">
		document.body.style.height=window.innerHeight+"px";
		//动态改变根元素字体大小
			function recalc() {
				var clientWidth = document.documentElement.clientWidth;
				if(!clientWidth) return;
				document.documentElement.style.fontSize = 40 * (clientWidth / 640) + 'px';
												//字体大小 = 1个rem单位表示多少个像素，设备的宽度 / 设计宽度
			}

			function initRecalc() {
				recalc();
				var resizeEvt = 'osrientationchange' in window ? 'orientationchange' : 'resize';
				if(!document.addEventListener) return;
				window.addEventListener(resizeEvt, recalc, false);
				document.addEventListener('DOMContentLoaded', recalc, false);
			}
			initRecalc();
		</script>
		<script language="javascript" type="text/javascript">  
			function leftTimer(year,month,day,hour,minute,second){ 
				var times = document.getElementsByClassName("times1");
			  var leftTime = (new Date(year,month-1,day,hour,minute,second)) - (new Date()); //计算剩余的毫秒数 
			  var days = parseInt(leftTime / 1000 / 60 / 60 / 24 , 10); //计算剩余的天数
			  var hours = parseInt(leftTime / 1000 / 60 / 60 % 24 , 10); //计算剩余的小时 
			  var minutes = parseInt(leftTime / 1000 / 60 % 60, 10);//计算剩余的分钟 
			  var seconds = parseInt(leftTime / 1000 % 60, 10);//计算剩余的秒数 
			  times[0].innerHTML = checkTime(days); 
			  times[1].innerHTML = checkTime(hours);
			  times[2].innerHTML = checkTime(minutes); 
			  times[3].innerHTML = checkTime(seconds); 
	//		  document.getElementById("timer").innerHTML = days+"天" + hours+"小时" + minutes+"分"+seconds+"秒";
//			  console.log(days+"天" + hours+"小时" + minutes+"分"+seconds+"秒");
			} 
			setInterval("leftTimer(2018,2,31,0,0,0)",1000); 
			function checkTime(i){ //将0-9的数字前面加上0，例1变为01 
			  if(i<10) 
			  { 
			    i = "0" + i; 
			  } 
			  return i; 
			} 
			  
		</script>
</html>
